{extend name="layout" /}
{block name="css"}<link rel="stylesheet" href="/style/admin.css" media="all">{/block}
{block name="title"}附件管理{/block}
{block name="content"}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto" lay-filter="app-attachment-list">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">用户ID</label>
                    <div class="layui-input-inline">
                        <input type="text" name="user_id" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">文件名称</label>
                    <div class="layui-input-inline">
                        <input type="text" name="file_name" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">文件类型</label>
                    <div class="layui-input-block">
                        <select name="file_type">
                            <option value="">请选择</option>
                            <option value="image">图片</option>
                            <option value="video">视频</option>
                            <option value="file">文件</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">文件路径</label>
                    <div class="layui-input-inline">
                        <input type="text" name="file_path" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="LAY-app-attachment-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </div>

        <div class="layui-card-body">
            <table id="LAY-app-attachment-list" lay-filter="LAY-app-attachment-list"></table>
            <script type="text/html" id="imgTpl">
                {{# if(d.file_type === 'image'){ }}
                <img style="display: inline-block; height: 32px;" src="{{ d.file_path }}"
                     layadmin-event="image_preview">
                {{# } else if(d.file_type === 'video'){ }}
                <i class="layui-icon layui-icon-video"
                   layadmin-event="video_preview" data-id="{{ d.id }}" style="font-size: 32px;"></i>
                {{# } }}
            </script>
            <script type="text/html" id="table-file-list">
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i
                        class="layui-icon layui-icon-delete"></i>删除</a>
            </script>
        </div>
    </div>
</div>
{/block}
{block name="js"}
<script>
    layui.use(['index', 'storage', 'table'], function () {
        var $ = layui.$
            , admin = layui.admin
            , view = layui.view
            , table = layui.table
            , form = layui.form;

        form.render(null, 'app-attachment-list');

        //监听搜索
        form.on('submit(LAY-app-attachment-search)', function (data) {
            var field = data.field;

            //执行重载
            table.reload('LAY-app-attachment-list', {
                where: field
            });
        });

    });
</script>
{/block}